package com.epam.bank;


public class Cashier {
	private static int count=0;
	private final int id=++count;
	private int amountEUR;
	private int amountUSD;
	private boolean enoughCash;

	public Cashier(int USD, int EUR) {
		this.amountUSD=USD;
		this.amountEUR=EUR;
		this.enoughCash=checkCash(amountUSD,amountEUR);
	}

	private boolean checkCash(int amountUSD, int amountEUR) {
		if (amountUSD < 250 || amountEUR<250) {
			return false;
		} else if (amountUSD >= 250 && amountEUR>=250) {
			return true;
		}
		return false;
	}
	
	public int getAmountEUR() {
		return amountEUR;
	}
	
	public int getAmountUSD() {
		return amountUSD;
	}
	
	public synchronized void incAmountUSD(int USD) {
		this.amountUSD+=USD;
		this.enoughCash=checkCash(amountUSD,amountEUR);
	}
	
	public synchronized void incAmountEUR(int EUR) {
		this.amountEUR+=EUR;
		this.enoughCash=checkCash(amountUSD,amountEUR);
	}
	
	public synchronized void decAmountUSD(int USD) {
		this.amountUSD-=USD;
		this.enoughCash=checkCash(amountUSD,amountEUR);
	}
	
	public synchronized void decAmountEUR(int EUR) {
		this.amountEUR-=EUR;
		this.enoughCash=checkCash(amountUSD,amountEUR);
	}

	public boolean isEnoughCash() {
		return enoughCash;
	}

	public int getId() {
		return id;
	}

}
